import axios from "axios";
import router from "../router";

// 创建axios
const service = axios.create({
  baseURL: "/api",
});

service.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    switch (error.response.status) {
      case 401: {
        router.push({ name: "LoginExam", params: { examId: 0 } });
        break;
      }
      case 402: {
        router.push({ name: "AdminLogin" });
        break;
      }
    }
  }
);

export default service;
